package micotime.com.amap_plugin.map.common;

import android.location.Location;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class LocationUtils {
    /**
     * 转化地址坐标
     * @param aMapLocation 定位信息
     * @return JSON字符串对象
     */
    public static  Map<String,Object> getLocationInfoMap(com.amap.api.location.AMapLocation aMapLocation) {
        Map<String, Object> map = new HashMap<>();
        map.put("lng", aMapLocation.getLongitude());
        map.put("lat", aMapLocation.getLatitude());
        map.put("province", aMapLocation.getProvince());
        map.put("city", aMapLocation.getCity());
        map.put("district", aMapLocation.getDistrict());
        map.put("address", aMapLocation.getAddress());
        map.put("speed", aMapLocation.getSpeed());
        map.put("errorCode",aMapLocation.getErrorCode());
        map.put("errorInfo",aMapLocation.getErrorInfo());

        return map;
    }

    public static Map<String,Object> getLocationInfoMap(Location location) {
        Map<String, Object> map = new HashMap<>();
        map.put("lng", location.getLongitude());
        map.put("lat", location.getLatitude());
        map.put("speed",location.getSpeed());
        return map;
    }

    public static Map<String,Object> getLocationInfoMap(Location location,int id) {
        Map<String, Object> map = new HashMap<>();
        map.put("lng", location.getLongitude());
        map.put("lat", location.getLatitude());
        map.put("speed", location.getSpeed());
        map.put("id",id);
        return map;
    }
}
